﻿using MediatR;
using S.Archives.Domain.S.ArchivesDto;
using S.Archives.Infrstructre.InterFace;
using S.Archives.Read.Api.Application.Command;
using System.Reflection.Metadata.Ecma335;

namespace S.Archives.Read.Api.Application.CommandHandlers
{
    /// <summary>
    /// 羊只档案详情
    /// </summary>
    public class GetSheepFilesDetailsCommandHandler : IRequestHandler<GetSheepFilesDetailsCommand, List<SheepFileDto>>
    {
        private readonly ISheepFileRepository sheepFile;

        public GetSheepFilesDetailsCommandHandler(ISheepFileRepository sheepFile)
        {
            this.sheepFile = sheepFile;
        }
        public async Task<List<SheepFileDto>> Handle(GetSheepFilesDetailsCommand request, CancellationToken cancellationToken)
        {
            var list = sheepFile.GetSheepFiles().Result;
            list=list.Where(x=>x.EarTag==request.EarTag).ToList();
            if (list.Count() > 0)
            {
                return list;
            }
            return null;
           
               
          

           
        }
    }
}
